package bosc.cn.model;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import lombok.*;

import java.time.LocalDateTime;

/**
 * 所有实体类的基础模型
 * 公共字段统一维护，避免重复定义
 */
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
@NoArgsConstructor
@AllArgsConstructor
public abstract class BaseModel<T extends BaseModel<?>> extends Model<T> {

    /**
     * 创建时间
     */
    @TableField("create_time")
    private LocalDateTime createTime;

    /**
     * 最后更新时间
     */
    @TableField("last_update_time")
    private LocalDateTime lastUpdateTime;

    /**
     * 最后更新操作
     */
    @TableField("last_update_operate")
    private String lastUpdateOperate;


    @SuppressWarnings("unchecked")
    public T setCreateTime(LocalDateTime createTime) {
        this.createTime = createTime;
        return (T) this;
    }

    @SuppressWarnings("unchecked")
    public T setLastUpdateTime(LocalDateTime lastUpdateTime) {
        this.lastUpdateTime = lastUpdateTime;
        return (T) this;
    }

    @SuppressWarnings("unchecked")
    public T setLastUpdateOperate(String lastUpdateOperate) {
        this.lastUpdateOperate = lastUpdateOperate;
        return (T) this;
    }
}
